<template>
	<view>
		<!-- <view class="" style="position: fixed;height: 100rpx;top: 0;left: 0;padding-top: 80rpx;width: 100%;background: #fff;z-index:100">
			<view class="" style="margin: 0 20rpx;display: flex;align-items: center;justify-content: space-between;height: 100rpx;">
					<u-search placeholder="请输入内容进行搜索" @clickIcon="change()" :showAction="false" :clearabled="true" v-model="search.content"></u-search>
			</view>
		</view> -->
		<view class="" style="padding:20rpx;display: flex;
		align-items: center;justify-content: space-between;background: #fff;border-bottom-left-radius: 20rpx;border-bottom-right-radius: 20rpx;margin-bottom: 20px;">
				<u-search placeholder="请输入内容进行搜索" @clickIcon="change()" :showAction="false" :clearabled="true" v-model="search.content"></u-search>
		</view>
		
		<view class="" style="margin: 20rpx 20rpx;margin-bottom: 100rpx;">
			<view class="" style="margin-bottom: 20rpx;background:#fff;padding:20rpx;border-radius: 20rpx;" v-for="(item,index) in list" >
				<view style="display: flex;align-items: center;justify-content: space-between;">
					<text>{{item.createtime}}</text>
					<!-- <text style="font-size: 24rpx;color: #007AFF;" @click="goAdd(item)">编辑</text> -->
					<view @click="goAdd(item)">
						<img src="@/static/imgs/edit.png" style="width:24rpx;height:24rpx;" alt="" srcset="" />
						<text style="font-size: 24rpx;color: #007AFF;" >编辑</text>
					</view>
				</view>
				
				<text-show linesCount="4" :imgs="item.imgs" :content="item.content" />
			</view>
			
		</view>

	</view>
</template>

<script>
	import TextShow from '@/components/text-show/text-show.vue'
	import DateTime from '@/components/date-time/date-time.vue'
	export default {
		comments:{
			TextShow,
			DateTime
		},
		data() {
			return {
				setCalShow:false,
				minDate:'',
				setDate:[],
				mode: 'range',
				search:{
					page:1,
					page_size:20,
					type:'summary',
					date1:'',
					date2:'',
					content:''
				},
				list:[],
				isLoading:false,
				
				
			}
		},
		onLoad() {
			
		},
		onShow(){
			this.setCalClose()
		},
		methods: {
			goAdd(item){
				this.$u.vuex('summaryItem', item)
				uni.navigateTo({
					url:'/pages/report/summaryReport',
				})
			},
			change(){
				this.setCalClose()
			},
			setCalClose(){
				this.setCalShow = false
				this.setDate = [];
				this.search.page = 1;
				this.list = []
				this.getList()
			},
			setCalShowOpen(){
				this.setCalShow = true
				this.defaultDateFunction()
			},
			defaultDateFunction() {
				let date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let day = date.getDate();
				if (month <= 9) {
					month = '0' + month;
				}
				if (day <= 9) {
					day = '0' + day;
				}
				let minyear = year - 1;
				this.minDate = minyear + '-' + month + '-' + day;
				let maxyear = year + 1;
				// this.maxDate = maxyear + '-'+ month +'-' + day; 最大日期可选到一年后
				this.setDate[0] = year + '-' + month + '-' + day;
			},
			setCalConfirm(e) {
				this.setDate = e;
				this.setCalShow = false
				this.search.page = 1;
				this.list = []
				this.getList()
			},
			getList(){
				this.isLoading = true; // 开始加载数据时设置标志位 
				if(this.setDate.length>1){
					this.search.date1 = this.setDate[0];
					this.search.date2 = this.setDate[this.setDate.length-1];
				}
				
				this.$api.report.list(this.search).then(res => {
					if(res.code == 1){
						this.list = this.list.concat(res.data.data);
						if(res.data.data.length == 0){
							this.$u.toast('没有数据了');
						}else{
							this.search.page += 1
						}
						this.isLoading = false;
						
					}
					
				})
			},
			onReachBottom() {  
			      // 滚动到底部时触发，如果不在加载中，则继续加载数据  
				  if(!this.isLoading){
					  this.getList()
				  }
				  
			},  
			onNavigationBarButtonTap(event) {
				this.$u.vuex('summaryItem', {})
				uni.navigateTo({
					url:'/pages/report/summaryReport'
				})
			},
		}
	}
</script>

<style scoped>
page{
	background-color: #f2f2f2;
}
</style>

